---
import ResetPasswordForm from '../components/Profile/ResetPasswordForm';
import SettingLayout from '../layouts/SettingLayout.astro';
---

<SettingLayout title='Reset Password'>
  <div class='container py-16'>
    <ResetPasswordForm client:load />
  </div>
</SettingLayout>

<script>
  import Cookies from 'js-cookie';
  import { TOKEN_COOKIE_NAME } from '../lib/constants';
  const token = Cookies.get(TOKEN_COOKIE_NAME);
  const urlParams = new URLSearchParams(window.location.search);
  const code = urlParams.get('code');

  if (!code || token) {
    window.location.href = '/settings/profile';
  }
</script>
